import {WebSocketServer} from 'ws'
import { positionData } from './testData.js'

const mockServer = new WebSocketServer({port: 7788})

function getRndInteger(minimum, maximum) {
  return Math.floor(Math.random() * (maximum - minimum)) + minimum;
}  

mockServer.on("connection", socket=> {
  const ti = setInterval(()=> {
    let randomx = getRndInteger(1, 69)
    let randomy = getRndInteger(1, 9)
    //let pos = {dev_id: "0001A", x: randomx, y: randomy}
    let msg = JSON.stringify(positionData.shift())
    //let msg = JSON.stringify(pos)
    console.log("a msg", msg)
    socket.send(msg)
  }, 1000)
})







